package com.example.venue_reservation_service.controller;

import com.example.venue_reservation_service.dto.HotDTO;
import com.example.venue_reservation_service.dto.PageDTO;
import com.example.venue_reservation_service.service.VenueHotService;
import com.example.venue_reservation_service.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/hot")
@CrossOrigin
@Api("热点事件管理")
public class HotController {

    @Resource
    private VenueHotService venueHotService;

    @ApiOperation("获取热点事件数据")
    @PostMapping("/query")
    public Result query(@RequestBody PageDTO dto){
        return venueHotService.getHots(dto);
    }

    @ApiOperation("添加")
    @PostMapping("/create")
    public Result create(@RequestBody HotDTO dto){
        return venueHotService.addHot(dto);
    }

    @ApiOperation("修改")
    @PostMapping("/update")
    public Result update(@RequestBody HotDTO dto){
        return venueHotService.updateHot(dto);
    }

    @ApiOperation("修改照片")
    @PostMapping("/upload")
    public Result upload(@RequestParam("file")MultipartFile file,
                         @RequestParam("id") Integer id){
        return venueHotService.uploadImg(file, id);
    }

    @ApiOperation("移除热点信息")
    @GetMapping("/remove")
    public Result remove(@RequestParam("id")Integer id){
        return venueHotService.removeHot(id);
    }

    @ApiOperation("加载今日营业总额")
    @GetMapping("/money")
    public Result money(){
        return venueHotService.getMoney();
    }

}
